﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Linq;
using Tong;
public partial class aspnet_testPargrameDir_site_Register : System.Web.UI.Page
{   /// <summary>
    /// 用於顯示資料
    /// </summary>
    public Tong.TongUse TextData = new Tong.TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    public string ho = "";

    /// <summary>
    /// 站点通用方法类
    /// </summary>
    public Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();


    //得到传入的栏目ID
    public String CloumnID = "1";

    /// <summary>
    /// 顯示當前欄目的簡介
    /// </summary>
    public string str1 = "";
    /// <summary>
    /// 資料表
    /// </summary>
    DataTable NewDt = new DataTable();
    /// <summary>
    /// 用于分頁的對像
    /// </summary>
    Tong.Fy.FenYe FY = new Tong.Fy.FenYe();

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            BindData();
        }
        catch { }


        //機構新聞
        MyDt = TextThisSite.GetPointCloumnNews("7", 999999, "0");//调用
        //  ShowMac.DataSource = MyDt;
        //  ShowMac.DataBind();
    }

    /// <summary>
    ///邦定當前頁面的資料
    /// </summary>
    void BindData()
    {
        try
        {

            CloumnID = Request.QueryString["SendentID"].Trim();
        }
        catch
        {
            CloumnID = Request.QueryString["CloumnID"].Trim();
        }

        // MyDt = TextData.SqlataSet("select * from [CX_Column]  where CX_Column_id=" + CloumnID).Tables[0];
        //// Descripation.Text = MyDt.Rows[0][Tong.DataOperation.Data_CX_Column._CX_Column_Explair].ToString();
        // ho = MyDt.Rows[0][Tong.DataOperation.Data_CX_Column._CX_Column_Name].ToString();
        // MainCase.DataSource = FY.Fy("select * from [CX_NEWS] where " + Tong.DataOperation.Data_CX_NEWS._CX_NEWS_Pic + " = 1 and " + Tong.DataOperation.Data_CX_NEWS._CX_NEWS_Class_id + "= " + TextThisSite.SiteGetNewsClassIDGiveCloumnID(CloumnID) + "   order by CX_NEWS_Sort desc,[CX_NEWS_PublicTime] desc, CX_NEWS_id desc  ", 12);
        //     MainCase.DataBind();
        //     Div.InnerHtml = FY.GetHTML;




    }



    /// <summary>
    /// 注册用户
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        string pwd = string.IsNullOrEmpty(Request.Form["pwd"]) ? string.Empty : Request.Form["pwd"];
        string user = string.IsNullOrEmpty(Request.Form["xm"]) ? string.Empty : Request.Form["xm"];
        string email = string.IsNullOrEmpty(Request.Form["email"]) ? string.Empty : Request.Form["email"];
        string com = string.IsNullOrEmpty(Request.Form["com"]) ? string.Empty : Request.Form["com"];
        string tel = string.IsNullOrEmpty(Request.Form["tel"]) ? string.Empty : Request.Form["tel"];
        string title = string.IsNullOrEmpty(Request.Form["title"]) ? string.Empty : Request.Form["title"];


        if (string.IsNullOrEmpty(stuid.Text))
        {
            TextData.ResonseAlert("请输入会员号");
            return;
        }

        string studid = stuid.Text;
        decimal stid = 0;
        decimal.TryParse(studid, out stid);
        JModel.DBEntities db = new JModel.DBEntities();
        var query = db.CX_Student.Where(p => p.学号 == stid);
        if (query.Count() == 0)
        {
            TextData.ResonseAlert("您输入的会员号不存在,请联系学样获取正确的会员号");
            return;
        }

        db.Connection.Close();
        db.Dispose();



        DataSet myds = TextData.SqlataSet("select * from RegUser where RegUser_Name='" + email + "'    ");

        if (myds.Tables.Count > 0)
        {
            if (myds.Tables[0].Rows.Count > 0)
            {

                TextData.ResonseAlert("你输入的电子邮件地址已经被别人注册过了,请用其它电子邮件地址注册");
                return;
            }
        }


        string sql = @"INSERT INTO [RegUser]
           ([RegUser_Name]
           ,[RegUser_Contont]
           ,[RegUser_PublicTime]
           ,[RegUser_Pic]
           ,[RegUser_Explier]
           ,[RegUser_Sort]
           ,[RegUser_CreatefileName]
           ,[RegUser_Link]
           ,[RegUser_LX])
     VALUES
           ('{0}'--<RegUser_Name, nvarchar(500),>
           ,'{1}'--<RegUser_Contont, text,>
           ,'{2}'--<RegUser_PublicTime, datetime,>
           ,'{3}'--<RegUser_Pic, nvarchar(500),>
           ,'{4}'--<RegUser_Explier, nvarchar(500),>
           ,{5}--<RegUser_Sort, int,>
           ,'{6}'--<RegUser_CreatefileName, nvarchar(50),>
           ,'{7}'--<RegUser_Link, nvarchar(500),>
           ,{8}--<RegUser_LX, int,>
)
";

        sql = string.Format(sql,
email//--<RegUser_Name, nvarchar(500),>
, tel//--<RegUser_Contont, text,>
, DateTime.Now//--<RegUser_PublicTime, datetime,>
, com//--<RegUser_Pic, nvarchar(500),>
, user//--<RegUser_Explier, nvarchar(500),>
, 0//--<RegUser_Sort, int,>
, pwd//--<RegUser_CreatefileName, nvarchar(50),>
, title//--<RegUser_Link, nvarchar(500),>
, stid//--<RegUser_LX, int,>

            );

        TextData.SqlDataSave(sql);


        TextData.ResonseAlert("注册成功!请牢记用户名和密码!");

    }
}
